package com.fx.usercenter.config;

import com.fx.usercenter.interceptions.LoginInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Component
public class MyConfig implements WebMvcConfigurer {

    //将拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**") //拦截所有的 url  /*** 拦截所有
                .excludePathPatterns("/user/login");
        //.excludePathPatterns("/user/test")//排除url: /user/login (登录)
        // .excludePathPatterns("/**/user/register"); //排除url: /user/reg   (注册)

    }
}